var myOrder = {
	noCouponTiphtml : '<div class="mod_empty_page"><div class="mod_empty_page_icon"><img src="themes/img/tip/59e46980N2658925e.png"></div> <p class="mod_empty_page_main">您当前无课程</p></div>'
};

//我的课程列表
//我的课程列表
myOrder.list = function(){
	var options = {
		userId:Feng.userId
	}	
	var ajax = new $ax(Feng.ctxPath+"/user/userCourse", function(data){        
//      console.log(data);
        if (data.success){
        	console.log(data);
        	//时间
        	template.helper('dateFormat', function (inp) {
		        if(inp!==""){
		            return inp.split(' ')[0];
		        }
		    });  
		     //状态
		    template.helper('courseStatusFormat', function (inp) {
		       if(inp==="1") return "<span class='fr uns'>未开课</span>";
		       else if(inp==="2") return "<span class='fr start'>已开课</span>";
		       else if(inp==="3") return "<span class='fr'>已结束</span>";
		    });  
		     //图片过滤器
		    template.helper('pictureFormat', function (inp) {
		       if(inp){
		           return Feng.ctxPath+"/file/getImage/"+inp;
		       }
		       else{
		        	return "themes/img/pd/course_defult.jpg";
		       }
		    });
//			未开课
		    if(data.obj.notStartCourse.length > 0){
		    	var outHtml = template("couponTempl",data.obj.notStartCourse);
    			$(".tab-panel-item:eq(0) .aui-content-box").html(outHtml);
		    }
		    else{
		    	$(".tab-panel-item:eq(0)").html(myOrder.noCouponTiphtml);
		    };
 //			已开课
		    if(data.obj.startCourse.length > 0){
		    	var outHtml = template("couponTempl",data.obj.startCourse);
    			$(".tab-panel-item:eq(1) .aui-content-box").html(outHtml);
		    }
		    else{
		    	$(".tab-panel-item:eq(1)").html(myOrder.noCouponTiphtml);
		    };
//			已结束
		    if(data.obj.endCourse.length > 0){
		    	var outHtml = template("couponTempl",data.obj.endCourse);
    			$(".tab-panel-item:eq(2) .aui-content-box").html(outHtml);
		    }
		    else{
		    	$(".tab-panel-item:eq(2)").html(myOrder.noCouponTiphtml);
		    };
 	
        }
        else if(data.code === 2){
        	Feng.open(data.msg);
        }
        else{
        	Feng.log("未查询到我的订单");
        }        
   },function(data){    	
        Feng.log("我的订单查询失败");
    });
    ajax.set(options);
    ajax.start();
}





myOrder.tab = function(){
	var $tab = $('#J_Tab');
	$tab.tab({
	    nav: '.tab-nav-item',
	    panel: '.tab-panel-item',
	    activeClass: 'tab-active'
	});
	
	$tab.find('.tab-nav-item').on('opened.ydui.tab', function (e) {
	    console.log('索引：%s - [%s]已经打开了', e.index, $(this).text());
	});

};


$(function(){
	myOrder.tab();
	
	myOrder.list();
	
//	lazyloadImg();
});
